#!/bin/bash

software_dir="translator"
venv_name="venamdgpu"
RUN_SCRIPT="run_${software_dir}.sh"

create_run_script() {
    echo "建立启动脚本"
    if [ ! -f "$RUN_SCRIPT" ]; then
        cat > "$RUN_SCRIPT" <<EOF
#!/bin/bash
source "$venv_name/bin/activate"
export HSA_OVERRIDE_GFX_VERSION=11.0.0
python -m manga_translator -v --mode web --use-gpu
EOF
        chmod +x "$RUN_SCRIPT"
    fi
}

#下载文件
[ ! -d "$software_dir" ] && git clone https://github.com/zyddnys/manga-image-translator.git $software_dir
cd $software_dir
[ ! -d "$venv_name" ] && python3 -m venv $venv_name
source $venv_name/bin/activate

#安装环境
pip3 install -r requirements.txt
pip3 uninstall -y torch torchvision
pip3 install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/rocm6.0
pip3 install git+https://github.com/kodalli/pydensecrf.git

#create_run_script


echo "安装完成"
